//
//  MeViewBtnCell.m
//  jingdongfang
//
//  Created by MTiMac02 on 2017/8/19.
//  Copyright © 2017年 kevinLY. All rights reserved.
//

#import "MeViewBtnCell.h"
#import "MeCellBtn.h"
#import "CollectViewController.h"
#import "ArtGalleryViewController.h"
#import "IGMyiGalleryVC.h"
#import "MyAltasViewController.h"

@interface MeViewBtnCell ()
{
    MeCellBtn *firstBtn;
    MeCellBtn *secondBtn;
    MeCellBtn *thirdBtn;
    MeCellBtn *fourthBtn;
}
@end
@implementation MeViewBtnCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
    {
        [self loadUI];
    }
    return self;
}

- (void)loadUI
{
    firstBtn = [[ MeCellBtn alloc] init];
    secondBtn = [[ MeCellBtn alloc] init];
    thirdBtn = [[ MeCellBtn alloc] init];
    fourthBtn = [[ MeCellBtn alloc] init];
    firstBtn.imageV.image=[UIImage imageNamed:@"hearth"];
    secondBtn.imageV.image=[UIImage imageNamed:@"cload-upload"];
    thirdBtn.imageV.image=[UIImage imageNamed:@"me-igallery"];
    fourthBtn.imageV.image=[UIImage imageNamed:@"me-pics"];
    [firstBtn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [secondBtn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [thirdBtn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [fourthBtn addTarget:self action:@selector(cellBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.contentView addSubview:firstBtn];
    [self.contentView addSubview:secondBtn];
    [self.contentView addSubview:thirdBtn];
    [self.contentView addSubview:fourthBtn];
}
- (void)cellBtnClick:(MeCellBtn *)btn
{
    if (btn == firstBtn)
    {

        [UIViewController ig_pushViewControllerClass:[CollectViewController class] animated:YES];
    }
    if (btn == secondBtn)
    {
        [UIViewController ig_pushViewControllerClass:[ArtGalleryViewController class] animated:YES];
    }
    if (btn == thirdBtn)
    {
        [UIViewController ig_pushViewControllerClass:[IGMyiGalleryVC class] animated:YES];
    }
    if (btn == fourthBtn)
    {
        MyAltasViewController *myAtrvVC = [[MyAltasViewController alloc] initWithNibName:@"MyAltasViewController" bundle:nil];
        [UIViewController ig_pushViewController:myAtrvVC animated:YES];
    }
}

- (void)layoutSubviews
{
    [super layoutSubviews];

    [firstBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(0);
        make.bottom.mas_equalTo(0);
    }];
    [secondBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(firstBtn.mas_right);
        make.width.mas_equalTo(firstBtn);
    }];
    [thirdBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.mas_equalTo(0);
        make.left.mas_equalTo(secondBtn.mas_right);
        make.width.mas_equalTo(firstBtn);
    }];
    [fourthBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.bottom.right.mas_equalTo(0);
        make.left.mas_equalTo(thirdBtn.mas_right);
        make.width.mas_equalTo(firstBtn);
    }];
    
    firstBtn.label.text = NSLocalizedString(@"Favorites", nil);
    secondBtn.label.text = NSLocalizedString(@"My Upload", nil);
    thirdBtn.label.text = NSLocalizedString(@"My iGallery", nil);
    fourthBtn.label.text = NSLocalizedString(@"My Album", nil);
    
//    firstBtn.numLabel.text=[NSString stringWithFormat:@"%@张",_model.collectionNums.length>0?_model.collectionNums:@"0"];
    firstBtn.numLabel.text=[NSString stringWithFormat:@"%@",_model.collectionNums.length>0?_model.collectionNums:@"0"];
    
    secondBtn.numLabel.text=[NSString stringWithFormat:@"%@",_model.worksNums.length>0?_model.worksNums:@"0"];
    thirdBtn.numLabel.text=[NSString stringWithFormat:@"%@",_model.totalEquNums.length>0?_model.totalEquNums:@"0"];
    fourthBtn.numLabel.text=[NSString stringWithFormat:@"%@",_model.albumNums.length>0?_model.albumNums:@"0"];
}


@end
